package demo4;
class Otu1{
    public  int date1=1;
    private  int date2=2;
    public  int  date3=3;
    //静态内部类
  public   static class Inter1{
        public int  date4=5;
        private   int date5=6;
        public static int date6=9;
        public void test(){
            Otu1 ot=new Otu1();
            System.out.println(ot.date1);
            System.out.println(ot.date2);
            System.out.println(ot.date3);
            System.out.println(date4);
            System.out.println(date5);
            System.out.println(date6);
            System.out.println("静态内部类test1方法执行了------");

        }
    }
}
class Otu2{
    public int date7=0;
    private int date8=8;
    public static int date0=12;
    //内部类
   public class Inter2{
        public int date7=18;
        public int date10=90;
        public int date13=78;
        private int date16=16;
        public void try1(){
            Otu2 ot3=new Otu2();
            System.out.println(date7);
            System.out.println(ot3.date7);
            System.out.println(ot3.date7);
            System.out.println(this.date7);
            System.out.println(date10);
            System.out.println(date13);
            System.out.println("内部类的test2执行了-----");
        }

    }
}
class Ot4{
    public  void test3(){
        System.out.println("HAHAHHA");
    }
}
interface IA{
    void test4();
}

public class Test82 {
    public void way1(){ //方法不能定义在方法中
        //局部类
        class Inner{
            public int date15;
            public void way2(){
                System.out.println("局部类的way方法实现了-----");
            }
        }
        Inner b=new Inner();
        b.way2();
    }
    public static void main(String[] args){
        IA a=new IA() {  //匿名类
            @Override
            public void test4() {
                System.out.println("miaomiaomaio");
            }
        };
        a.test4();
    //实例化一个实例内部类对象
    Otu2 ot4=new Otu2();//先创建外部类的对象
    Otu2.Inter2 n= ot4.new Inter2();//格式左边外部类名.内部类名 变量名=外部类型的变量名.new 内部类名();
    n.try1();
    //实例化一个静态内部类对象不需实例外部类对象
    Otu1.Inter1 m=new Otu1.Inter1();//格式外部类名.静态内部类名 变量名=new 外部类名。内部类名();
    m.test();

}}
